package 
{
	import flash.events.MouseEvent;
	import flash.geom.Rectangle;
	
	/**
	 * ...
	 * @author DarkGoodWIN
	 */
	public class TNaperstokShop extends TCaseRoom 
	{
		private var Cont1: TContainer = null;
		
		public override function CurrentCont(): TContainer
		{
			return Cont1;
		}

		public function OnBayPrise2(O: Object): void
		{
			Info.Money = O.Money;
			UpdateMoneyText();
			Info.FillPrises(O.Prises, O.PrisesOnCase);
		}
		
		private var CurPrise: TPrise = null; //todo: remove
		
		private function OnBay(e: MouseEvent): void
		{
			if (CurPrise == null)
				return;
			if (Info.Prises[CurPrise.ID] > StringUtils.MaxCharCode)
			{				
				new TModalMessage("Вы больше <br>не можете покупать <br><b> " + CurPrise.Hint + " </b>");
				return;
			}
			Info.VKNaperstokAPI.BayPrise(CurPrise.ID, CurPrise.Price, Info.Prises, OnBayPrise2);
		}
		
		public override function OnPriseClick(P: TPrise): void
		{
			CurPrise = P;
			var Mess: TModalMessage = new TModalMessage('Вы хотите купить<br><b>' + P.Hint + '</b><br> за ' + P.Price + ' бублей?', false);
			Mess.AddBtn("Хочу!!", OnBay, true);
			Mess.AddCloseBtn("Потом");
		}
		
		
		private function AddPrizes(): void
		{
			for (var i: int = 1; i < 7; ++i)
				AddPrize(i);
		}
		
		public function TNaperstokShop(anInfo: TNaperstokInfo): void
		{
			super(anInfo);
			Cont1 = new TContainer(this, 10, 90, 520, 120);
			AddPrizes();
		}
	}
	
}